]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
overviewControls: Handle keyboard navigation
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 24 Jan 2022 16:00:36 +0000 (17:00 +0100)
committerMarge Bot <marge-bot@gnome.org>
Thu, 27 Jan 2022 22:49:42 +0000 (22:49 +0000)
The old view selector used to handle initiating keynav into pages.
That code became inactive when non-search related functionality
was moved elsewhere, and was finally removed in commit cf41f4a527.

We still want the keynav behavior it provided, so add similar code
to overview's control manager.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4056

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2124>

js/ui/overviewControls.js

index 7a77b3250084d862a20da9ee531d43806b58b4c2..2344ad8eb085097631d51c7e31ba3575ede98c4f 100644 (file)
@@ -435,6 +435,41 @@ class ControlsManager extends St.Widget {
                 Main.overview.toggle();
         });
 
+        // connect_after to give search controller first dibs on the event
+        global.stage.connect_after('key-press-event', (actor, event) => {
+            if (this._searchController.searchActive)
+                return Clutter.EVENT_PROPAGATE;
+
+            if (global.stage.key_focus &&
+                !this.contains(global.stage.key_focus))
+                return Clutter.EVENT_PROPAGATE;
+
+            const { finalState } =
+                this._stateAdjustment.getStateTransitionParams();
+            let keynavDisplay;
+
+            if (finalState === ControlsState.WINDOW_PICKER)
+                keynavDisplay = this._workspacesDisplay;
+            else if (finalState === ControlsState.APP_GRID)
+                keynavDisplay = this._appDisplay;
+
+            if (!keynavDisplay)
+                return Clutter.EVENT_PROPAGATE;
+
+            const symbol = event.get_key_symbol();
+            if (symbol === Clutter.KEY_Tab || symbol === Clutter.KEY_Down) {
+                keynavDisplay.navigate_focus(
+                    null, St.DirectionType.TAB_FORWARD, false);
+                return Clutter.EVENT_STOP;
+            } else if (symbol === Clutter.KEY_ISO_Left_Tab) {
+                keynavDisplay.navigate_focus(
+                    null, St.DirectionType.TAB_BACKWARD, false);
+                return Clutter.EVENT_STOP;
+            }
+
+            return Clutter.EVENT_PROPAGATE;
+        });
+
         Main.wm.addKeybinding(
             'toggle-application-view',
             new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),